#!/usr/bin/env php
<?php
/**
* For `X.Y.Z`, use current branch, last commit message, & available tag names to determine the next tag/release version
* Assumes you have already run git fetch --tags to download the names of all tags
*
* outputs
*/
require_once(__DIR__.'/../src/VersionBumper.php');
$version_bumper = new \Tlf\Scrawl\VersionBumper();
$current_branch_version = $version_bumper->get_branch_version($version_bumper->get_current_branch());
if (substr($current_branch_version, 0,2) == "0."){
// For 0.X.Y.Z
// 0.X are based on branch
// .Y.Z are based on these bump rules
$bump_rules = [
2 => [ 'feature' ],
3 => [ 'bugfix', 'other' ],
];
} else {
$bump_rules = [
// For X.Y.Z.G where X >= 1
// X is based on branch
// Y is based on 'feature:' prefix
// Z is based on 'bugfix:' prefix
// G is based on 'other:' prefix
// 0.X are based on branch
// .Y.Z are based on these bump rules
// 0-based indexes!
// 0 is not used, this depends on the branch
1 => [ 'feature' ],
2 => [ 'bugfix' ],
3 => [ 'other' ],
];
}
$new_version = $version_bumper->get_new_version_from_git($bump_rules);
if ($current_branch_version == $new_version){
echo "error";
} else {
echo $new_version;
}